package com.cy.security.interceptor;


import com.cy.security.util.JwtUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class TokenInterceptor implements HandlerInterceptor{

 @Override
 public boolean preHandle(HttpServletRequest request,HttpServletResponse response,Object handler) throws Exception{
  System.out.println("=====preHandler======");
  String token=
 // request.getParameter("Authentication");
  request.getHeader("Authentication");
  if(token==null||"".equals(token))
   throw new RuntimeException("please login");
   boolean flag=JwtUtils.isTokenExpired(token);
   if(flag)
      throw new RuntimeException("login timeout");
  return true;
 }
}
